from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
import time

cap = {
  "platformVersion": "7.1.2",
  "platformName": "Android",
  "deviceName": "d2q",
  "appPackage": "com.threegene.doctor",
  "appActivity": ".module.splash.SplashActivity"
}

driver = webdriver.Remote("http://localhost:4723/wd/hub",cap)
driver.implicitly_wait(15)
# 通过id方式点击同意
driver.find_element(MobileBy.ID,"com.threegene.doctor:id/agree_user_agreement_btn").click()
# 滑动第一次
time.sleep(3)
TouchAction(driver).press(x = 693,y = 1022).move_to(x = 43,y = 977).release().perform()
# driver.swipe(start_x=659,start_y=506,end_x=56,end_y=567)
time.sleep(3)
# 滑动第二次
TouchAction(driver).press(x = 693,y = 1022).move_to(x = 43,y = 977).release().perform()
# driver.swipe(start_x=693,start_y=1022,end_x=43,end_y=977)
time.sleep(2)
# 通过x和y坐标点击
TouchAction(driver).tap(x = 350,y = 1113).perform()

# 获取登录文本信息
text = driver.find_element(MobileBy.XPATH,"//*[@text='登录']").text
assert text == "登录"



